﻿using System.Web;
using System.Web.Hosting;
using Navigant.Mapping;

namespace Navigant.SharePointWcfSupport
{
    public class WcfVirtualPathProviderRegModule : IHttpModule
    {
        static bool initialized = false;
        static object locker = new object();

        public void Init(HttpApplication context)
        {
            if (!initialized)
            {
                lock (locker)
                {
                    if (!initialized)
                    {
                        WcfVirtualPathProvider provider = new WcfVirtualPathProvider();
                        HostingEnvironment.RegisterVirtualPathProvider(provider);
                        MappingInitializer.CreateMaps();
                        initialized = true;
                    }
                }
            }
        }

        public void Dispose()
        {
        }
    }
}
